/**
 *
 */
package xin.xihc.validtor;

/**
 * 验证返回结果
 *
 * @author xihc
 * @version 1.0
 * @date 2018年09月19日
 */
public class ValidateResult {

    private boolean success = true;// 验证结果
    private String fieldName;// 字段名称
    private String msg;// 提示消息

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    /**
     * @return the fieldName
     */
    public String getFieldName() {
        return fieldName;
    }

    /**
     * @param fieldName the fieldName to set
     */
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    /**
     * @return the msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * @param msg the msg to set
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 校验成功
     *
     * @return
     */
    public ValidateResult toSuccess() {
        this.setFieldName(null);
        this.setMsg("验证通过");
        this.setSuccess(true);
        return this;
    }

    /**
     * 校验失败
     *
     * @param fieldName
     * @param msg
     * @return
     */
    public ValidateResult toFail(String fieldName, String msg) {
        this.setFieldName(fieldName);
        this.setMsg(msg);
        this.setSuccess(false);
        return this;
    }
}
